package 蓝桥杯;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/11/20
 */
public class main {

    public static void main(String[] args) {

        System.out.println(main.fib(4));
        System.out.print(main.fib(4,1));
    }

    public static int fib(int x) {

        if (x == 1) {
            return 1;
        }
        return x * fib(x - 1);
    }

    // 尾递归
    public static int fib(int x,int result) {
        if (x == 1) {
            return result;
        }
        return fib(x-1,x * result);
    }
}
